import Vue from 'vue'
import VueRouter from 'vue-router'
import {BootstrapVue} from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

import Axios from 'axios'
import App from './App.vue'
import layer from 'layui-layer'
import config from './global_config.js'
// import Home from './components/pages/Home.vue'
// import Shop from './components/pages/Shop.vue'
// import Order from './components/pages/Order.vue'
// import Me from './components/pages/Me.vue'

Vue.use(BootstrapVue)
Vue.use(VueRouter)
Vue.config.productionTip = false
Vue.prototype.$axios = Axios
Vue.prototype.$msg = (content, options) => {
    let opt = config.layer.msg;
    if (options != null) {
        Object.keys(options).forEach(k => {
            opt[k] = options[k]
        })
    }

    layer.msg(content, opt)
}

const router = new VueRouter({
    routes: [
        {
            path: '/',
            name: 'home',
            component: () => import('./components/pages/Home.vue'),
            alias: '/home'
        },
        {
            path: '/shop',
            name: 'shop',
            component: () => import('./components/pages/Shop.vue')
        },
        {
            path: '/cart',
            name: 'cart',
            component: () => import('./components/pages/Cart.vue')
        },
        {
            name: 'cart-settlement',
            path: '/cart/settlement',
            component: () => import('./components/pages/Cart/Settlement')
        },
        {
            path: '/me',
            name: 'me',
            component: () => import('./components/pages/Me.vue')
        },
        {
            name: 'me-address',
            path: '/me/address',
            component: () => import('./components/pages/Me/Address')
        },
        {
            name: 'me-security',
            path: '/me/security',
            component: () => import('./components/pages/Me/Security')
        },
        {
            name: 'me-orders',
            path: '/me/orders',
            component: () => import('./components/pages/Me/Orders')
        }
    ]
})

new Vue({
    el: '#app',
    router,
    render: h => h(App)
})
